package cn.btks.resultintegration.rule.controller;

import cn.btks.commonserver.result.ResultState;
import cn.btks.commonserver.result.StateInfo;
import cn.btks.resultintegration.rule.dto.rule.YlxzbbQueryParam;
import cn.btks.resultintegration.rule.pojo.Ylxzbb;
import cn.btks.resultintegration.rule.service.YlxzbbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author lijun
 * @Date 2021/2/19 11:04
 */
@RestController
@RequestMapping("api/v1.0/resultIntegration/rule")
@Api(tags = "规则模块")
@Validated
public class YlxzbbController {

    @Autowired
    YlxzbbService ylxzbbService;

    @PostMapping("/ylxzbb/findPages")
    @ApiOperation("《引领性指标表》分页条件查询")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string"),
    })
    public ResultState findPages(@RequestBody YlxzbbQueryParam param) {
        return  ylxzbbService.findPages(param);
    }

    @GetMapping("/ylxzbb/findAll")
    @ApiOperation("《引领性指标表》查询所有")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "token密匙", required = true, dataType = "string"),
    })
    public ResultState findAll() {
        List<Ylxzbb> list = ylxzbbService.findAll();
        return CollectionUtils.isNotEmpty(list) ? new ResultState(StateInfo.FIND_OK.getCode(),StateInfo.FIND_OK.getMsg(), list) :
                new ResultState(StateInfo.FIND_NULL.getCode(),StateInfo.FIND_NULL.getMsg());
    }
}
